<template>
  <div class="bookContent">
    <div class="bookImgContent">
      <div><img :src="bookDetaile.coverUrl" alt="" /></div>
      <div class="infoList">
        <div class="bookName">
          {{ bookDetaile.bookTitle
          }}<span>{{ bookDetaile.authorName }} {{$t("home.book")}}</span>
        </div>
        <div class="labelContent"><span>{{bookDetaile.category.name}}</span></div>
        <div class="numberBook">
          {{$t("home.AfterCompletingThis")}}<span>|</span>{{ bookDetaile.wordCount }}{{$t("home.words")}}
        </div>
        <div><div class="downloadApp"><a href="https://yuwan.juzimoo.com/fishball/pro/1623749464969-app-com.yhzy.fishball-fishball_beijing_104665138-release-v2.2.1-221.apk">{{$t("home.downloadApp")}}</a></div></div>
      </div>
    </div>
    <div class="inforContent">
      <div class="inforText">
        <div class="inforTitle">
          <span>{{$t("home.bookDescription")}}</span>
        </div>
        <div>
          <p>{{ bookDetaile.bookIntro }}</p>
        </div>
        <div class="recommend" v-if="$i18n.locale == 'zh'">
          <div class="recommendTitle">{{$t("home.peopleWhoLikeTheBookLikeIt")}}</div>
          <div class="recommendList">
            <div
              v-for="(item, index) in LikeBook"
              :key="index"
              @click="goDetaile(item.bookId)"
            >
              <img :src="item.coverUrl" alt="" />{{ item.bookTitle }}
            </div>
          </div>
        </div>
      </div>
      <div class="ercodeContent">
        <img src="../../assets/home/bookInforEe.png" alt="" />
        <p>{{$t("home.readWithYou")}}</p>
        <div>{{$t("home.scanCodeDownload")}}</div>
      </div>
    </div>
  </div>
</template>
<script>
import { showBookInfo, getUserLikeBook } from "@/api/newHome";
export default {
  name: "bookInfor",
  data() {
    return {
      bookDetaile: {},
      LikeBook: [],
    };
  },
  methods: {
    goDetaile(id) {
      this.getBookInfor(id)
      // this.getLikeList(id,categoryId)
    },
    getBookInfor(id) {
      showBookInfo({ bookId: id }).then((res) => {
        if (res.code == 1) {
          this.bookDetaile = res.source;
          this.getLikeList(id,this.bookDetaile.category.categoryId)
        }
      });
    },
    getLikeList(id,CategoryId){
      getUserLikeBook({ bookId:id,categoryId:CategoryId  }).then((res) => {
      this.LikeBook = res.source;
    });
    }
  },
  mounted() {
    this.getBookInfor(this.$route.query.bookId)
    this.getLikeList(this.$route.query.bookId,this.$route.query.categoryId)
  },
};
</script>
<style lang="scss" scoped="scoped">
.bookContent {
  background-color: #fff;
  width: 1200px;
  margin:0 auto;
  margin-top: 80px;
  border-radius: 0.4rem;
  padding: 2rem;
  .bookImgContent {
    display: flex;
    img {
      width: 190px;
      height: 254px;
      margin-right: 1rem;
      border-radius: 1rem;
    }
    .bookName {
      font-size: 24px;
      span {
        font-size: 14px;
        margin-left: 10px;
      }
    }
    .numberBook {
      span {
        margin: 0 10px;
      }
    }
    .infoList {
      display: flex;
      flex-direction: column;
      justify-content: space-around;
      .labelContent span {
        border: 1px solid #ccc;
        background-color: #f1f1f1;
        border-radius: 4px;
        font-size: 12px;
        padding: 2px 10px;
      }
      .downloadApp {
        background-color: #3385fd;
        color: #fff;
        font-weight: 600;
        text-align: center;
        width: 140px;
        height: 48px;
        border-radius: 10px;
        line-height: 47px;
        a{
          color:#fff
        }
      }
    }
  }
}
.inforContent {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
  .inforText {
    flex: 1;
    p {
      font-size: 14px;
    }
  }
  .inforTitle {
    border-bottom: 1px solid #f1f1f1;
    line-height: 65px;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 20px;
    span {
      // border-bottom: 8px solid #3385fd;
    }
  }
}
.recommend {
  margin-top: 20px;
  .recommendTitle {
    border-bottom: 1px solid #f1f1f1;
    line-height: 45px;
    font-weight: bold;
    font-size: 20px;
    margin-bottom: 20px;
  }
  .recommendList {
    display: flex;
    justify-content: space-between;
    > div {
      display: flex;
      flex-direction: column;
      align-items: center;
    }
    img {
      border-radius: 10px;
      width: 118px;
      height: 158px;
      margin-bottom: 10px;
    }
  }
}
.ercodeContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-around;
  width: 280px;
  height: 458px;
  background-color: #f1f1f1;
  margin-left: 20px;
  border-radius: 4px;
  img {
    width: 150px;
    height: 150px;
  }
  p {
    color: #3385fd;
    font-size: 18px;
  }
}
</style>